package com.hongyu.manager.media.manager.controller.app;

import com.hongyu.manager.media.manager.controller.base.BaseController;
import com.hongyu.manager.media.manager.model.bean.Txt;
import com.hongyu.manager.media.manager.model.bean.Video;
import com.hongyu.manager.media.manager.model.bean.WebSite;
import com.hongyu.manager.media.manager.model.http.RequestLog;
import com.hongyu.manager.media.manager.model.result.Result;
import com.hongyu.manager.media.manager.model.result.ResultBuilder;
import com.hongyu.manager.media.manager.service.TxtService;
import com.hongyu.manager.media.manager.service.VideoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Controller
@CrossOrigin
@RequestMapping("/op/hongyu/avtt/app/txt")
public class AppTxtController extends BaseController {
    private static final Logger LOG = LoggerFactory.getLogger(AppVideoController.class);
    @Autowired
    TxtService txtService;

    @PostMapping("/list")
    @ResponseBody
    @RequestLog(value = "分页列表")
    public Object lis(@RequestParam(defaultValue = "")String query, @RequestParam(defaultValue = "")String webSite, @RequestParam(defaultValue = "")String typeName, @RequestParam(defaultValue = "0") Integer regionId, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, HttpServletRequest request, HttpServletResponse response){

            Txt txt=new Txt();
            txt.setWebSite(webSite);
            txt.setTitle(typeName);
            txt.setStart((pageNum - 1) * pageSize);
            txt.setPageSize(pageSize);
            List<Txt> videoList=txtService.getList(txt);
            Result<List<Txt>> result = requestService.returnSuccess(new ResultBuilder<List<Txt>>(), "登录成功，正在跳转 ...");
            result.setData(videoList);
            return result;
    }
    @PostMapping("/find")
    @ResponseBody
    @RequestLog(value = "分页列表")
    public Object find(@RequestParam(defaultValue = "")String website,@RequestParam(defaultValue = "0")Integer id){
        Txt txt=txtService.findTxt(id);
        Result<Txt> result = requestService.returnSuccess(new ResultBuilder<Txt>(), "登录成功，正在跳转 ...");
        result.setData(txt);
        return result;

    }
    @PostMapping("/website/list")
    @ResponseBody
    @RequestLog(value = "网站分页列表")
    public Object webList(){

        return requestService.returnSuccess("");
    }

    @PostMapping("/play/times/update")
    @ResponseBody
    @RequestLog(value = "更新播放次数")
    public Object updatePalyTimes(@RequestParam(defaultValue = "")String website,@RequestParam(defaultValue = "0")Integer id){


        return requestService.returnSuccess("");
    }

    @PostMapping("type/list")
    @ResponseBody
    @RequestLog(value = "更新播放次数")
    public Object typeList(@RequestParam(defaultValue = "")String webSite){

        return requestService.returnSuccess("");
    }
}
